package com.robotic.sensor.domain;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.robotic.common.annotation.Excel;
import com.robotic.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

/**
 * 区域边界定义对象 region_boundary
 * 
 * @author robotic
 * @date 2024-01-20
 */
@TableName("region_boundary")
public class RegionBoundary extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    @TableId(type = IdType.AUTO)
    private Long id;

    /** 区域代码 */
    @Excel(name = "区域代码")
    private String regionCode;

    /** 区域名称 */
    @Excel(name = "区域名称")
    private String regionName;

    /** 边界类型(rectangle/polygon/circle) */
    @Excel(name = "边界类型", readConverterExp = "rectangle=矩形,polygon=多边形,circle=圆形")
    private String boundaryType;

    /** 边界坐标数据(JSON格式存储) */
    @Excel(name = "边界坐标数据")
    private String boundaryData;

    /** 最小X坐标(用于快速筛选) */
    @Excel(name = "最小X坐标")
    private BigDecimal minX;

    /** 最大X坐标(用于快速筛选) */
    @Excel(name = "最大X坐标")
    private BigDecimal maxX;

    /** 最小Y坐标(用于快速筛选) */
    @Excel(name = "最小Y坐标")
    private BigDecimal minY;

    /** 最大Y坐标(用于快速筛选) */
    @Excel(name = "最大Y坐标")
    private BigDecimal maxY;

    /** 最小Z坐标(用于快速筛选) */
    @Excel(name = "最小Z坐标")
    private BigDecimal minZ;

    /** 最大Z坐标(用于快速筛选) */
    @Excel(name = "最大Z坐标")
    private BigDecimal maxZ;

    /** 优先级(数值越小优先级越高，用于重叠区域判断) */
    @Excel(name = "优先级")
    private Integer priority;

    /** 状态(1启用 0禁用) */
    @Excel(name = "状态", readConverterExp = "1=启用,0=禁用")
    private String status;

    /** 描述信息 */
    @Excel(name = "描述信息")
    private String description;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    
    public void setRegionCode(String regionCode) 
    {
        this.regionCode = regionCode;
    }

    public String getRegionCode() 
    {
        return regionCode;
    }
    
    public void setRegionName(String regionName) 
    {
        this.regionName = regionName;
    }

    public String getRegionName() 
    {
        return regionName;
    }
    
    public void setBoundaryType(String boundaryType) 
    {
        this.boundaryType = boundaryType;
    }

    public String getBoundaryType() 
    {
        return boundaryType;
    }
    
    public void setBoundaryData(String boundaryData) 
    {
        this.boundaryData = boundaryData;
    }

    public String getBoundaryData() 
    {
        return boundaryData;
    }
    
    public void setMinX(BigDecimal minX) 
    {
        this.minX = minX;
    }

    public BigDecimal getMinX() 
    {
        return minX;
    }
    
    public void setMaxX(BigDecimal maxX) 
    {
        this.maxX = maxX;
    }

    public BigDecimal getMaxX() 
    {
        return maxX;
    }
    
    public void setMinY(BigDecimal minY) 
    {
        this.minY = minY;
    }

    public BigDecimal getMinY() 
    {
        return minY;
    }
    
    public void setMaxY(BigDecimal maxY) 
    {
        this.maxY = maxY;
    }

    public BigDecimal getMaxY() 
    {
        return maxY;
    }
    
    public void setMinZ(BigDecimal minZ) 
    {
        this.minZ = minZ;
    }

    public BigDecimal getMinZ() 
    {
        return minZ;
    }
    
    public void setMaxZ(BigDecimal maxZ) 
    {
        this.maxZ = maxZ;
    }

    public BigDecimal getMaxZ() 
    {
        return maxZ;
    }
    
    public void setPriority(Integer priority) 
    {
        this.priority = priority;
    }

    public Integer getPriority() 
    {
        return priority;
    }
    
    public void setStatus(String status) 
    {
        this.status = status;
    }

    public String getStatus() 
    {
        return status;
    }
    
    public void setDescription(String description) 
    {
        this.description = description;
    }

    public String getDescription() 
    {
        return description;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("regionCode", getRegionCode())
            .append("regionName", getRegionName())
            .append("boundaryType", getBoundaryType())
            .append("boundaryData", getBoundaryData())
            .append("minX", getMinX())
            .append("maxX", getMaxX())
            .append("minY", getMinY())
            .append("maxY", getMaxY())
            .append("minZ", getMinZ())
            .append("maxZ", getMaxZ())
            .append("priority", getPriority())
            .append("status", getStatus())
            .append("description", getDescription())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }

    /**
     * 检查指定坐标是否在当前区域的边界框内(快速筛选)
     *
     * @param x X坐标
     * @param y Y坐标
     * @param z Z坐标
     * @return true-在边界框内，false-不在边界框内
     */
    public boolean isInBoundingBox(BigDecimal x, BigDecimal y, BigDecimal z) {
        if (minX != null && x.compareTo(minX) < 0) return false;
        if (maxX != null && x.compareTo(maxX) > 0) return false;
        if (minY != null && y.compareTo(minY) < 0) return false;
        if (maxY != null && y.compareTo(maxY) > 0) return false;
        if (minZ != null && z.compareTo(minZ) < 0) return false;
        if (maxZ != null && z.compareTo(maxZ) > 0) return false;
        return true;
    }
}